package com.saltlux.tdd.paginate;

import junit.framework.Assert;

import org.junit.Test;

public class PaginateBuilderTester {
	@Test
	public void buildSimpleGroupedPaginate() {
		PaginateBuilder builder = new PaginateBuilder();

		builder.setTotalDocumentCount(123);
		Paginate paginate = builder.build();

		Assert.assertTrue(paginate instanceof GroupedPaginate);
		Assert.assertEquals(PaginateBuilder.DEFAULT_CURRENTPAGE,
				paginate.getCurrentPage());
		Assert.assertEquals(123, paginate.getTotalDocumentCount());
		Assert.assertEquals(PaginateBuilder.DEFAULT_PAGESIZE,
				paginate.getPageSize());
		Assert.assertEquals(PaginateBuilder.DEFAULT_PAGEGROUPSIZE,
				paginate.getPagegroupSize());

		builder.setTotalDocumentCount(120);
		Paginate paginate2 = builder.build();
		Assert.assertEquals(120, paginate2.getTotalDocumentCount());
	}

	@Test
	public void buildComplexGroupedPaginate() {
		PaginateBuilder builder = new PaginateBuilder();
		builder.setTotalDocumentCount(123);
		builder.setPageSize(11);
		builder.setPagegroupSize(11);
		builder.setCurrentPage(3);

		Paginate paginate = builder.build();

		Assert.assertEquals(3, paginate.getCurrentPage());
		Assert.assertEquals(11, paginate.getPageSize());
		Assert.assertEquals(11, paginate.getPagegroupSize());
	}

}
